<?php
require_once('environment.php');
if($acc->isLogged()) $temp->addSubMenu("Change eStore Page", "estore.php?admin=mod");

switch(fixArr($_GET, "admin")){
    default:
        $temp->currentPage("Home >> eStore");
        $temp->setTab(5);
        $temp->generate();
        $sql = $db->Execute("SELECT * FROM `monster`.`frontPage` WHERE `AutoInc` = ? LIMIT 1", array(6));
        if($sql->RecordCount() < 1) {
            print "I'm sorry, but there seems to be a problem accessing our database.<br />\nPlease inform a website administrator about this problem.";
        }else {
            $row = $sql->FetchRow();
            print nl2br(stripslashes($row['Text']));
        }
        break;
    case("mod"):
        if(!$acc->isLogged()) die(change_site("account.php"));
        $temp->currentPage("Home >> eStore >> Change eStore Page");
        $temp->setTab(5,0);
        $temp->generate();
        if(!fixArr($_POST, "data")) {
            $sql = $db->Execute("SELECT * FROM `monster`.`frontPage` WHERE `AutoInc` = ? LIMIT 1", array(6));
            if($sql->RecordCount() == 1) {
                $row = $sql->FetchRow();
                print "<form method=\"POST\" action=\"\">\n";
                print "<textarea name=\"data\" rows=\"20\" cols=\"60\">".$row['Text']."</textarea><br />\n";
                print "<br /><input type=\"submit\" value=\"Update\" /> <input type=\"reset\" value=\"Reset\" />\n";
                print "</form>\n";
            }
        }else {
            $data = fixArr($_POST, "data");
            $data = stripslashes($data);
            $db->Execute("UPDATE `monster`.`frontPage` SET `Text` = ? WHERE `AutoInc` = '6' LIMIT 1", array($data));
            $acc->adminGPS("Edited eStore page.");
            print "The eStore has been changed successfully.";
        }
        break;
}
?>